package com.jy.datapipeline.common.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class CorsConfig implements WebMvcConfigurer {
    static final String ORIGINS[] = new String[] { "GET", "POST", "PUT", "DELETE" };
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")//项目中的所有接口都支持跨域
            .allowedOrigins("*")//所有地址都可以访问，也可以配置具体地址
            .allowCredentials(false)
            .allowedMethods("*")//"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"
            .maxAge(36000);// 跨域允许时间
    }

    public void map() {
        Map<String, Object> map = new HashMap<>();
        map.put("A", 1001);
        map.put("B", 1001);
    }
}
